﻿
@{
    if (Model.ResultInfo.DocType == null|| Model.ResultInfo.Master==null)
    {
    <center>没有数据</center>
        return;
    }
    ViewBag.Title = Model.ResultInfo.CurrentType.TypeName + "-" + Model.ResultInfo.Master.MasterName + PubConst.SitePrefix;
    if (Model.ResultInfo.DocType.Where(it => it.Level == 2).First().Id == Model.ResultInfo.CurrentType.Id)
    {
        ViewBag.Title =  Model.ResultInfo.DocContent.First().Title+"-"  + PubConst.SitePrefix;
    }
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.PageNum = 2;
    var type = Model.ResultInfo.DocType;
    var fist = type.Where(it => it.Level == 1).ToList();
}
@using Infrastructure.ViewModels
@using Infrastructure.Pub;
@using SyntacticSugar
@section css{
    <link href="~/_theme/ueditor/utf8-net/third-party/SyntaxHighlighter/shCoreDefault.css" rel="stylesheet" />
    <link href="~/_theme/css/page/doc.css?v=@MvcApplication.Version" rel="stylesheet" />
    <link href="~/_theme/css/fonts/fonts.css?v=@MvcApplication.Version" rel="stylesheet" />
}
@section js{
    <script src="~/_theme/ueditor/utf8-net/third-party/SyntaxHighlighter/shCore.js"></script>
    <script type="text/javascript">SyntaxHighlighter.all();</script>
    <script>
        setTimeout(function () {
            layui.jquery("td.code").each(function () {
                var th = layui.jquery(this);
                if (th.width() > 900) {
                    th.addClass("scroll");
                }
            })
        }, 1000);
    </script>
}
@model ResultModel<DocResult>
<div class="layui-main site-inline">
    <div class="site-tree">
        <ul class="layui-tree">
            <li >
                <form id="frmSearch" action="/home/DocSearch?masterId=@Model.ResultInfo.MasterId&typeId=@Model.ResultInfo.TypeId" class="fly-search" method="get">
                    <i onclick="frmSearch.submit()" class="iconfont icon-sousuo"></i>
                    <input type="hidden" name="masterId" value="@Model.ResultInfo.MasterId">
                    <input class="layui-input" autocomplete="off" value="" placeholder="搜索内容，回车跳转" type="text" name="title">
                </form>
            </li>
            @if (type.IsValuable() && fist.IsValuable())
            {

                foreach (var item in fist)
                {
                    var itemChildren = type.Where(it => item.Id == it.ParentId).ToList();
                    <li class="clear"><h2>@item.TypeName</h2></li>
                    foreach (var childItem in itemChildren.OrderByDescending(it=>it.Sort))
                    {
                        <li class="@((type.Count>25&&fist.Count>1?"site-float":"")) site-tree-noicon @((Model.ResultInfo.CurrentType.Id==childItem.Id).IIF("layui-this",""))">
                            <a href="@Url.Action("Doc",new { typeId=childItem.Id})"><cite>@childItem.TypeName</cite></a>
                        </li>
                    }
                }
            }
        </ul>
    </div>
    <div class="site-content">
        @if (Model.ResultInfo.DocContent.IsValuable())
        {
            var list = Model.ResultInfo.DocContent.Where(it => it.TypeId == Model.ResultInfo.CurrentType.Id).ToList();
            foreach (var item in list)
            {
                <h1 class="site-h1">@item.Title</h1>
                <div>
                    @if (ViewBag.IsAdmin == true)
                    {
                        <a class="admin-button" target="_blank" href="/AdminSite/DocContent/PageDCAdd?id=@item.Id">管理</a>
                    }
                    @Html.Raw(item.Content)

                    @if (!string.IsNullOrEmpty(item.Script))
                    {
                        @section appendJs{
                        <script>
                            @Html.Raw(item.Script)
                        </script>
                       }
                    }
                </div>
            }
        }
    </div>
</div>
<div class="site-tree-mobile layui-hide">
    <i class="layui-icon"></i>
</div>